// 时间戳转现在时间格式
const timeStamp2String = (time,type) =>  { // time=>时间戳、 type=>转换类型
    var datetime = new Date();
    datetime.setTime(time);
    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
    var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
    var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
    var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
    if (type == '1') {
        return year + "年" + month + "月" + date + "日";
    }
    if (type == '2') {
        return year + "-" + month + "-" + date;
    }
    if (type == '3') {
        return month + "-" + date;
    }
    if (type == '4') {
        return month;
    }
    if (type == '5') {
        return date;
    }
    if (type == '6') {
        return year + "." + month + "." + date + " " + hour + ":" + minute + ":" + second;
    }
    if (type == '7') {
        return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
    }
    if (type == '8') {
        return year + "-" + month + "-" + date + " " + hour + ":" + minute;
    }
    if (type == '9') {
        return month + "-" + date + " " + hour + ":" + minute;
    }
}

export default timeStamp2String